package router

import (
	"github.com/gin-gonic/gin"
	"weibo_1006/internal/middleware"
	"weibo_1006/internal/service"
)

func Router(r *gin.Engine) {
	api := r.Group("/api")
	{
		//图片上传
		r.POST("upload", service.UploadFile)
		//短信发送
		r.POST("sendSms", service.SendSms)

		//用户
		user := api.Group("/user")
		{
			//注册
			user.POST("register", service.RegisterUser)
			//登陆
			user.POST("login", service.LoginUser)
			//认证
			user.Use(middleware.Auth())
			//个人资料
			user.POST("addInfo", service.AddUserInfo)
		}

		//微博内容
		weibo := api.Group("/weibo")
		{
			//发布
			weibo.POST("addWeibo", service.AddWeibo)
			//删除
			weibo.POST("deleteWeibo", service.DeleteWeibo)
			//转发
			weibo.GET("findWeibo", service.FindWeibo)
			//评论
			weibo.POST("comment", service.CommentWeibo)
			//显示评论
			weibo.GET("commentList", service.CommentListWeibo)
			//删除评论
			weibo.POST("deleteComment", service.CommentDeleteWeibo)
		}

		//关注
		follow := api.Group("/follow")
		{
			//关注用户
			follow.POST("addFollow", service.AddFollow)
			//取消关注
			follow.POST("deleteFollow", service.DeleteFollow)
			//获取粉丝列表
			follow.GET("listFindFollow", service.ListFindFollow)
		}

		//话题
		topic := api.Group("/topic")
		{
			//话题创建
			topic.POST("add", service.AddTopic)
			//参与讨论
			topic.POST("send", service.SendTopic)
			//话题排行榜
			topic.GET("list", service.ListTopic)
		}
	}
}
